import { Controller, Get, Post, UseGuards } from '@nestjs/common';
import { AuthService } from '@/modules/auth/auth.service';
import { JwtAuthGuard } from '@/modules/auth/jwt-auth.guard';
import { AuthGuard } from '@nestjs/passport';

@Controller('/auth')
export class AuthController {
  constructor(private readonly authService: AuthService) {}

  @Get('user')
  @UseGuards(JwtAuthGuard)
  getUser() {
    return this.authService.getUser();
  }

  @Post('/login')
  @UseGuards(AuthGuard('local'))
  login() {
    return this.authService.getUser();
  }

  @Get('optional-user')
  @UseGuards(new JwtAuthGuard({ optional: true }))
  optionalUser() {
    return this.authService.getUser();
  }
}
